//
//  ARTWatchHistoryCell.m
//  ChartsDemo
//
//  Created by yunda on 2021/10/12.
//

#import "ARTWatchHistoryCell.h"

@implementation ARTWatchHistoryCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    // xib
    static NSString *ID = @"ARTWatchHistoryCell";
    ARTWatchHistoryCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (void)setModel:(ARTWatchHisModel *)model{
    _model = model;
    _left1Label.text = [NSString stringWithFormat:@"%@%ld",FYLocalizedString(@"oxygen_max_value", @""),model.spo2Max];
    _left2Label.text = [NSString stringWithFormat:@"%@%ld",FYLocalizedString(@"oxygen_mini_value", @""),model.spo2Min];
    _left3Label.text = [NSString stringWithFormat:@"%@%ld",FYLocalizedString(@"oxygen_average_value", @""),model.spo2Avg];
    
    _right1Label.text = [NSString stringWithFormat:@"%@%ld",FYLocalizedString(@"oxygen_heart_max_value", @""),model.prMax];
    _right2Label.text = [NSString stringWithFormat:@"%@%ld",FYLocalizedString(@"oxygen_heart_mini_value", @""),model.prMin];
    _right3Label.text = [NSString stringWithFormat:@"%@%ld",FYLocalizedString(@"oxygen_heart_average_value", @""),model.prAvg];
    
    _idLabel.text = [NSString stringWithFormat:@"ID:%@",@(model.ID+1)];
    if (model.type == ARTWatchMonitorTypeDaily) {
        _typeImageView.image = J_ImageNamed(@"watch_ic_daily-1");
        _typeTitleLabel.text = [FYLocalizeableMode stringOfDailyTitle];
    }else if (model.type == ARTWatchMonitorTypeSleep){
        _typeImageView.image = J_ImageNamed(@"watch_ic_sleep-1");
        _typeTitleLabel.text = [FYLocalizeableMode stringOfSleepTitle];
    }
    
    NSString *date = @"--";
    NSString *time = @"--";
    if ([model.date containsString:@" "]) {
        NSArray *array = [model.date componentsSeparatedByString:@" "];
        if (array.count == 2) {
            date = array[0];
            time = array[1];
        }
    }
    _dateLabel.text =  date;
    _timeLabel.text = [NSString stringWithFormat:@"%@%@  %@%@",FYLocalizedString(@"oxygen_time_test", @""),time,FYLocalizedString(@"oxygen_time_Long", @""),[Tool getMMSSFromSS:model.longTime]];
    
    if (model.lookState == 1) {
        _nextImageView.image = J_ImageNamed(@"commen_ic_remind");
    }else{
        _nextImageView.image = J_ImageNamed(@"commen_ic_more");
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
